﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITM495.OOExamples.Core.BeeHive
{
    public class RoboBee: Robot, IWorker
    {
        private int shiftstoWork;
        private int shiftsWorked;

        public RoboBee(string name, string[] jobs)
        {
            JobsICanDo = jobs;
            Name = name;
        }

        #region IWorker Members

        public string Name { get; private set; }
        public string[] JobsICanDo { get; private set; }

        public String Job { get; protected set; }

        public int ShiftsLeft { get { return shiftstoWork - shiftsWorked; } }

        public bool WorkOneShift()
        {
            if (String.IsNullOrEmpty(Job))
                return false;

            shiftsWorked++;

            if (shiftsWorked > shiftstoWork)
            {
                shiftsWorked = 0;
                shiftstoWork = 0;
                Job = "";
                return true;
            }


            return false;

        }

        public bool DoThisJob(string job, int numberOfShifts)
        {
            if (!String.IsNullOrEmpty(Job))
                return false;

            var canDo = JobsICanDo.Contains(job);

            if (canDo)
            {
                Job = job;
                shiftstoWork = numberOfShifts;
                shiftsWorked = 0;
            }

            return canDo;
        }

        #endregion
    }
}